package com.linkdood.app.web.rest;

import com.linkdood.app.service.HsgService;
import com.linkdood.app.vm.OrganizationCommunityVm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.FixedOrderComparator;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调用好家好社区平台接口示例
 *
 * @author lxy
 */
@Slf4j
@RestController
@RequestMapping("/api/hsg")
public class HsgResource {

    private final HsgService hsgService;

    public HsgResource(HsgService hsgService) {
        this.hsgService = hsgService;
    }

    @ApiOperation(value = "获取经纬度附近社区和小区信息")
    @GetMapping("/organizations/range")
    public ResponseEntity<?> getOrganizationCommunityByLocation(@RequestParam(value = "coordinate") String coordinate,
                                                                @RequestParam(value = "distance") Integer distance) {
        List<OrganizationCommunityVm> results = hsgService.listOrganizationCommunityByDistance(coordinate, distance);
        return ResponseEntity.ok(results);
    }

}
